# 使用8080访问dashboard
mkdir -p /home/traefik/conf
mkdir -p /home/traefik/cert
touch /home/traefik/cert/fsgit-cc-acme.json
chmod 600 /home/traefik/cert/fsgit-cc-acme.json

# docker脚本
cat <<EOF | sudo tee /home/traefik/docker-compose.yml
version: "3.3"
services:
  traefik:
    image: "traefik"
    container_name: "traefik"
    network_mode: "host"
    restart: "unless-stopped"
    volumes:
      - "/home/traefik/:/etc/traefik/"
      - "/var/run/docker.sock:/var/run/docker.sock"
    command:
      - "--log.level=ERROR"
      - "--accesslog=true"
      - "--api=true"
      - "--api.insecure=true"
      - "--api.dashboard=true"
      - "--entrypoints.websecure.address=:443"
      - "--entrypoints.web.address=:80"
      - "--providers.docker=true"
      - "--providers.docker.endpoint=tcp://192.168.1.11:2377"
      - "--providers.docker.swarmMode=true"
      #- "--providers.docker.exposedbydefault=false" # 只暴露带有traefik.enable=true的容器
      - "--providers.file.directory=/etc/traefik/conf"
      - "--providers.file.watch=true"
EOF

cd /home/traefik/
docker-compose down -v
docker-compose up -d
docker logs traefik